<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>档案管理</title>
		<!-- Tell the browser to be responsive to screen width -->
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
		<link rel="stylesheet" href="../static/css/bootstrap.min.css">
		<link rel="stylesheet" href="../static/css/font-awesome.min.css">
		<link rel="stylesheet" href="../static/css/AdminLTE.min.css">
		<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
		<link rel="stylesheet" href="../static/css/all-skins.min.css">
		<link rel="stylesheet" href="../static/css/main.css">
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
  <style type="text/css">
    	body{
    		background: url(../static/image/background.png) no-repeat;
    	}
    </style>
	</head>

	<body>
		<div class="login-box" id="rrapp" v-cloak style="margin: 30% auto 1% auto;">
			<!-- <div class="login-logo">
				<b>档案管理</b>
			</div> -->
			<div class="login-box-body">
				<!-- <p class="login-box-msg">用户注册</p> -->
				<div v-if="error" class="alert alert-danger alert-dismissible">
					<h4 style="margin-bottom: 0px;"><i class="fa fa-exclamation-triangle"></i> {{errorMsg}}</h4>
				</div>
				<div class="form-group has-feedback">
					<input type="text" class="form-control" v-model="username" placeholder="账号">
					<span class="glyphicon glyphicon-user form-control-feedback"></span>
				</div>
				<div class="form-group has-feedback">
					<input type="text" class="form-control" v-model="password" placeholder="密码">
					<span class="glyphicon glyphicon-lock form-control-feedback"></span>
				</div>

				<div class="row">
					<div class="col-xs-8">
						<div class="checkbox icheck">
						</div>
					</div>
					<div class="col-xs-4">
						<button type="button" class="btn btn-danger btn-block btn-flat" @click="regist">注册</button>
					</div>
				</div>

			</div>
		</div>
		<script src="../static/libs/jquery.min.js"></script>
		<script src="../static/plugins/jqgrid/jquery.jqGrid.min.js"></script>
		<script src="../static/libs/vue.min.js"></script>
		<script src="../static/libs/bootstrap.min.js"></script>
		<script src="../static/libs/app.js"></script>
		<script src="../static/js/validations.js"></script>
		<script type="text/javascript">
			var vm = new Vue({
				el: '#rrapp',
				data: {
					username: '',
					password: '',
					captcha: '',
					error: false,
					errorMsg: '',
					src: 'captcha.jpg'
				},
				beforeCreate: function() {
					if(self != top) {
						top.location.href = self.location.href;
					}
				},
				methods: {
					regist: function() {
						var data = "username=" + vm.username + "&password=" + vm.password + "&captcha=" + vm.captcha;
						$.ajax({
							type: "GET",
							url: baseURL + "sys/regist",
							data: data,
							dataType: "json",
							success: function(r) {
								if(r.code == 0) { //登录成功
									parent.location.href = 'login.html';
								} else {
									vm.error = true;
									vm.errorMsg = r.msg;

									vm.refreshCode();
								}
							}
						});
					}
				}
			});
		</script>
	</body>

</html>